package com.hd.crdao.view;

import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.hd.crdao.R;


/**
 *
 *@author Programming
 *@date 2017/5/19 0019
 */

public class ExpandHeadView extends RelativeLayout  {


    public ImageView mHeadViewLeftArrow;
    public TextView mHeadViewLeftText;
    public TextView mHeadViewMidText;
    public TextView mHeadViewRightText;
    public ImageView mHeadViewRightPlus;
    public LinearLayout mLeftArrowLL;

    public ExpandHeadView(Context context) {
        this(context, null);
    }

    public ExpandHeadView(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public ExpandHeadView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);

        View view = LayoutInflater.from(context).inflate(R.layout.expandheadview, this, true);
        mLeftArrowLL = (LinearLayout) view.findViewById(R.id.leftarrowll);
        mHeadViewLeftArrow = (ImageView) view.findViewById(R.id.headviewleftarrow);
        mHeadViewLeftText = (TextView) view.findViewById(R.id.headviewlefttext);
        mHeadViewMidText = (TextView) view.findViewById(R.id.headviewmidtext);
        mHeadViewRightText = (TextView) view.findViewById(R.id.headviewrighttext);
        mHeadViewRightPlus = (ImageView) view.findViewById(R.id.headviewrightplus);

        TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.ExpandHeadView);

        //是否可以显示
        boolean leftarrow = ta.getBoolean(R.styleable.ExpandHeadView_headview_leftarrow, false);
        boolean rightplusDisplays = ta.getBoolean(R.styleable.ExpandHeadView_headview_rightplus, false);
        boolean leftTextDisplays = ta.getBoolean(R.styleable.ExpandHeadView_headview_lefttextdisplay, false);
        boolean rightTextDisplays = ta.getBoolean(R.styleable.ExpandHeadView_headview_righttextdisplay, false);
        boolean midTextDisplays = ta.getBoolean(R.styleable.ExpandHeadView_headview_midtextdisplay, false);
        //设置文本
        String leftText = ta.getString(R.styleable.ExpandHeadView_headview_lefttext);
        String midText = ta.getString(R.styleable.ExpandHeadView_headview_midtext);
        String rightText = ta.getString(R.styleable.ExpandHeadView_headview_righttext);


        ta.recycle();

        mHeadViewLeftText.setText(leftText);
        mHeadViewRightText.setText(rightText);
        mHeadViewMidText.setText(midText);

        mHeadViewLeftArrow.setVisibility(leftarrow ? View.VISIBLE : View.GONE);
        mHeadViewLeftText.setVisibility(leftTextDisplays ? View.VISIBLE : View.GONE);
        mHeadViewMidText.setVisibility(midTextDisplays ? View.VISIBLE : View.GONE);
        mHeadViewRightText.setVisibility(rightTextDisplays ? View.VISIBLE : View.GONE);
        mHeadViewRightPlus.setVisibility(rightplusDisplays ? View.VISIBLE : View.GONE);

    }

    public ImageView getHeadViewLeftArrow() {
        return mHeadViewLeftArrow;
    }

    public void setHeadViewLeftArrow(ImageView headViewLeftArrow) {
        mHeadViewLeftArrow = headViewLeftArrow;
    }

    public TextView getHeadViewLeftText() {
        return mHeadViewLeftText;
    }

    public void setHeadViewLeftText(TextView headViewLeftText) {
        mHeadViewLeftText = headViewLeftText;
    }

    public TextView getHeadViewMidText() {
        return mHeadViewMidText;
    }

    public void setHeadViewMidText(TextView headViewMidText) {
        mHeadViewMidText = headViewMidText;
    }

    public TextView getHeadViewRightText() {
        return mHeadViewRightText;
    }

    public void setHeadViewRightText(TextView headViewRightText) {
        mHeadViewRightText = headViewRightText;
    }

    public ImageView getHeadViewRightPlus() {
        return mHeadViewRightPlus;
    }

    public void setHeadViewRightPlus(ImageView headViewRightPlus) {
        mHeadViewRightPlus = headViewRightPlus;
    }

    public LinearLayout getLeftArrowLL() {
        return mLeftArrowLL;
    }

    public void setLeftArrowLL(LinearLayout leftArrowLL) {
        mLeftArrowLL = leftArrowLL;
    }
}


